package com.sdk.bigdata.client;


import com.sdk.bigdata.exceptions.DataConfigLoadException;
import com.sdk.bigdata.exceptions.PropertiesLoadException;
import com.sdk.bigdata.model.DataConfig;


public class DataClientFactory {

    private volatile static DataClient dataClient;

    // 使用项目目录下的config.properties文件
    public static DataClient getDataClient() throws PropertiesLoadException {
        if (null == dataClient) {
            synchronized (DataClient.class) {
                if (null == dataClient) {
                    dataClient = new DataClient();
                }
            }
        }
        return dataClient;
    }

    // 自定义config,不适用config.properties文件
    public static DataClient getDataClient(DataConfig config) throws DataConfigLoadException {
        if (null == dataClient) {
            synchronized (DataClient.class) {
                if (null == dataClient) {
                    dataClient = new DataClient(config);
                }
            }
        }
        return dataClient;
    }
}
